﻿<!--//Copyright (c) 2008 Jason Kemp
//
//Permission is hereby granted, free of charge, to any person obtaining a copy
//of this software and associated documentation files (the "Software"), to deal
//in the Software without restriction, including without limitation the rights
//to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
//copies of the Software, and to permit persons to whom the Software is
//furnished to do so, subject to the following conditions:
//
//The above copyright notice and this permission notice shall be included in
//all copies or substantial portions of the Software.
//
//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
//IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
//FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
//AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
//LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
//OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
//THE SOFTWARE.-->
    <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    x:Class="Topics.Radical.Windows.Behaviors.AutoComplete"
                    x:ClassModifier="public">
    
    <Style TargetType="TextBox" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
           xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
           xmlns:s="clr-namespace:System;assembly=mscorlib" 
           xmlns:mwt="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Aero"
           xmlns:local="clr-namespace:Topics.Radical.Windows.Behaviors"
           x:Key="autoCompleteTextBoxStyle">
        <Style.BasedOn>
            <Style TargetType="TextBoxBase">
                <Style.Resources>
                    <CollectionViewSource x:Key="viewSource" />
                </Style.Resources>
                <Setter Property="TextElement.Foreground">
                    <Setter.Value>
                        <DynamicResource ResourceKey="{x:Static SystemColors.ControlTextBrushKey}" />
                    </Setter.Value>
                </Setter>
                <Setter Property="Panel.Background">
                    <Setter.Value>
                        <DynamicResource ResourceKey="{x:Static SystemColors.WindowBrushKey}" />
                    </Setter.Value>
                </Setter>
                <Setter Property="Border.BorderBrush">
                    <Setter.Value>
                        <LinearGradientBrush StartPoint="0,0" EndPoint="0,20" MappingMode="Absolute">
                            <LinearGradientBrush.GradientStops>
                                <GradientStop Color="#FFABADB3" Offset="0.05" />
                                <GradientStop Color="#FFE2E3EA" Offset="0.07" />
                                <GradientStop Color="#FFE3E9EF" Offset="1" />
                            </LinearGradientBrush.GradientStops>
                        </LinearGradientBrush>
                    </Setter.Value>
                </Setter>
                <Setter Property="Border.BorderThickness">
                    <Setter.Value>
                        <Thickness>1,1,1,1</Thickness>
                    </Setter.Value>
                </Setter>
                <Setter Property="Control.Padding">
                    <Setter.Value>
                        <Thickness>1,1,1,1</Thickness>
                    </Setter.Value>
                </Setter>
                <Setter Property="UIElement.AllowDrop">
                    <Setter.Value>
                        <s:Boolean>True</s:Boolean>
                    </Setter.Value>
                </Setter>
                <Setter Property="FrameworkElement.FocusVisualStyle">
                    <Setter.Value>
                        <x:Null />
                    </Setter.Value>
                </Setter>
                <Setter Property="Control.Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="TextBoxBase">
                            <StackPanel  >
                                <mwt:ListBoxChrome Background="{TemplateBinding Panel.Background}" BorderBrush="{TemplateBinding Border.BorderBrush}" BorderThickness="{TemplateBinding Border.BorderThickness}" RenderMouseOver="{TemplateBinding UIElement.IsMouseOver}" RenderFocused="{TemplateBinding UIElement.IsKeyboardFocusWithin}" Name="Bd" SnapsToDevicePixels="True">
                                    <ScrollViewer Name="PART_ContentHost" SnapsToDevicePixels="{TemplateBinding UIElement.SnapsToDevicePixels}" />
                                </mwt:ListBoxChrome>
                                <Popup x:Name="autoCompletePopup" 
                                       Placement="Bottom" 
                                       PlacementTarget="{Binding ElementName=Bd}"
                                       StaysOpen="False"                                       
                                       AllowsTransparency="True">
                                    <ListBox x:Name="autoCompleteListBox"
                                             ItemsSource="{Binding Source={StaticResource viewSource}}">
                                        <ListBox.ItemContainerStyle>
                                            <Style TargetType="ListBoxItem">
                                                <Setter Property="HorizontalContentAlignment" Value="Stretch" />
                                            </Style>
                                        </ListBox.ItemContainerStyle>
                                    </ListBox>
                                </Popup>
                            </StackPanel>
                            <ControlTemplate.Triggers>
                                <Trigger Property="UIElement.IsEnabled">
                                    <Setter Property="Panel.Background" TargetName="Bd">
                                        <Setter.Value>
                                            <DynamicResource ResourceKey="{x:Static SystemColors.ControlBrushKey}" />
                                        </Setter.Value>
                                    </Setter>
                                    <Setter Property="TextElement.Foreground">
                                        <Setter.Value>
                                            <DynamicResource ResourceKey="{x:Static SystemColors.GrayTextBrushKey}" />
                                        </Setter.Value>
                                    </Setter>
                                    <Trigger.Value>
                                        <s:Boolean>False</s:Boolean>
                                    </Trigger.Value>
                                </Trigger>
                            </ControlTemplate.Triggers>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
        </Style.BasedOn>
        <Style.Resources>
            <ResourceDictionary />
        </Style.Resources>
    </Style>
    <Style TargetType="ComboBox" 
           xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
           xmlns:s="clr-namespace:System;assembly=mscorlib" 
           xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
           xmlns:mwt="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Aero"
           x:Key="autoCompleteComboBoxStyle">
        <Style.Resources>
            <CollectionViewSource x:Key="viewSource" />
        </Style.Resources>
        <Style.Triggers>
            <Trigger Property="ComboBox.IsEditable">
                <Setter Property="Border.BorderBrush">
                    <Setter.Value>
                        <LinearGradientBrush StartPoint="0,0" EndPoint="0,20" MappingMode="Absolute">
                            <LinearGradientBrush.GradientStops>
                                <GradientStop Color="#FFABADB3" Offset="0.05" />
                                <GradientStop Color="#FFE2E3EA" Offset="0.07" />
                                <GradientStop Color="#FFE3E9EF" Offset="1" />
                            </LinearGradientBrush.GradientStops>
                        </LinearGradientBrush>
                    </Setter.Value>
                </Setter>
                <Setter Property="Panel.Background">
                    <Setter.Value>
                        <DynamicResource ResourceKey="{x:Static SystemColors.WindowBrushKey}" />
                    </Setter.Value>
                </Setter>
                <Setter Property="KeyboardNavigation.IsTabStop">
                    <Setter.Value>
                        <s:Boolean>False</s:Boolean>
                    </Setter.Value>
                </Setter>
                <Setter Property="Control.Padding">
                    <Setter.Value>
                        <Thickness>3,3,3,3</Thickness>
                    </Setter.Value>
                </Setter>
                <Setter Property="Control.Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="ComboBox">
                            <Grid Name="Placement" SnapsToDevicePixels="True">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="*" />
                                    <ColumnDefinition Width="Auto" />
                                </Grid.ColumnDefinitions>
                                <Popup IsOpen="False" Placement="Bottom" PopupAnimation="{DynamicResource {x:Static SystemParameters.ComboBoxPopupAnimationKey}}" AllowsTransparency="True" Name="PART_Popup" Grid.ColumnSpan="2">
                                    <mwt:SystemDropShadowChrome Color="#00FFFFFF" Name="Shdw" MinWidth="0" MaxHeight="{TemplateBinding ComboBox.MaxDropDownHeight}">
                                        <Border BorderThickness="1,1,1,1" BorderBrush="{DynamicResource {x:Static SystemColors.WindowFrameBrushKey}}" Background="{DynamicResource {x:Static SystemColors.WindowBrushKey}}" Name="DropDownBorder">
                                            <ScrollViewer>
                                                <ItemsPresenter SnapsToDevicePixels="{TemplateBinding UIElement.SnapsToDevicePixels}" KeyboardNavigation.DirectionalNavigation="Contained" />
                                            </ScrollViewer>
                                        </Border>
                                    </mwt:SystemDropShadowChrome>
                                </Popup>
                                <mwt:ListBoxChrome Background="{TemplateBinding Panel.Background}" BorderBrush="{TemplateBinding Border.BorderBrush}" BorderThickness="{TemplateBinding Border.BorderThickness}" RenderMouseOver="{TemplateBinding UIElement.IsMouseOver}" RenderFocused="{TemplateBinding UIElement.IsKeyboardFocusWithin}" Name="Border" Grid.ColumnSpan="2" />
                                <TextBox IsReadOnly="False" HorizontalContentAlignment="{TemplateBinding Control.HorizontalContentAlignment}" VerticalContentAlignment="{TemplateBinding Control.VerticalContentAlignment}" Name="PART_EditableTextBox" Margin="{TemplateBinding Control.Padding}" xml:space="preserve"><TextBox.Style><Style TargetType="TextBox"><Style.Resources><ResourceDictionary /></Style.Resources><Setter Property="FrameworkElement.OverridesDefaultStyle"><Setter.Value><s:Boolean>True</s:Boolean></Setter.Value></Setter><Setter Property="UIElement.AllowDrop"><Setter.Value><s:Boolean>True</s:Boolean></Setter.Value></Setter><Setter Property="FrameworkElement.MinWidth"><Setter.Value><s:Double>0</s:Double></Setter.Value></Setter><Setter Property="FrameworkElement.MinHeight"><Setter.Value><s:Double>0</s:Double></Setter.Value></Setter><Setter Property="FrameworkElement.FocusVisualStyle"><Setter.Value><x:Null /></Setter.Value></Setter><Setter Property="Control.Template"><Setter.Value><ControlTemplate TargetType="TextBox"><ScrollViewer HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden" Background="#00FFFFFF" Name="PART_ContentHost" Focusable="False" /></ControlTemplate></Setter.Value></Setter></Style></TextBox.Style></TextBox>
                                <ToggleButton IsChecked="False" Grid.Column="1">
                                    <ToggleButton.Style>
                                        <Style TargetType="ToggleButton">
                                            <Style.Resources>
                                                <ResourceDictionary />
                                            </Style.Resources>
                                            <Setter Property="FrameworkElement.OverridesDefaultStyle">
                                                <Setter.Value>
                                                    <s:Boolean>True</s:Boolean>
                                                </Setter.Value>
                                            </Setter>
                                            <Setter Property="KeyboardNavigation.IsTabStop">
                                                <Setter.Value>
                                                    <s:Boolean>False</s:Boolean>
                                                </Setter.Value>
                                            </Setter>
                                            <Setter Property="UIElement.Focusable">
                                                <Setter.Value>
                                                    <s:Boolean>False</s:Boolean>
                                                </Setter.Value>
                                            </Setter>
                                            <Setter Property="ButtonBase.ClickMode">
                                                <Setter.Value>
                                                    <x:Static Member="ClickMode.Press" />
                                                </Setter.Value>
                                            </Setter>
                                            <Setter Property="Control.Template">
                                                <Setter.Value>
                                                    <ControlTemplate TargetType="ToggleButton">
                                                        <mwt:ButtonChrome Background="{TemplateBinding Panel.Background}" BorderBrush="{TemplateBinding Border.BorderBrush}" RenderMouseOver="{TemplateBinding UIElement.IsMouseOver}" RenderPressed="{TemplateBinding ButtonBase.IsPressed}" RoundCorners="False" Name="Chrome" Width="{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}" SnapsToDevicePixels="True">
                                                            <Path Data="M0,0L3.5,4 7,0z" Fill="#FF000000" Name="Arrow" Margin="0,1,0,0" HorizontalAlignment="Center" VerticalAlignment="Center" />
                                                        </mwt:ButtonChrome>
                                                        <ControlTemplate.Triggers>
                                                            <Trigger Property="ToggleButton.IsChecked">
                                                                <Setter Property="mwt:ButtonChrome.RenderPressed" TargetName="Chrome">
                                                                    <Setter.Value>
                                                                        <s:Boolean>True</s:Boolean>
                                                                    </Setter.Value>
                                                                </Setter>
                                                                <Trigger.Value>
                                                                    <s:Boolean>True</s:Boolean>
                                                                </Trigger.Value>
                                                            </Trigger>
                                                            <Trigger Property="UIElement.IsEnabled">
                                                                <Setter Property="Shape.Fill" TargetName="Arrow">
                                                                    <Setter.Value>
                                                                        <SolidColorBrush>#FFAFAFAF</SolidColorBrush>
                                                                    </Setter.Value>
                                                                </Setter>
                                                                <Trigger.Value>
                                                                    <s:Boolean>False</s:Boolean>
                                                                </Trigger.Value>
                                                            </Trigger>
                                                        </ControlTemplate.Triggers>
                                                    </ControlTemplate>
                                                </Setter.Value>
                                            </Setter>
                                        </Style>
                                    </ToggleButton.Style>
                                </ToggleButton>
                                <Popup x:Name="autoCompletePopup" 
                                       Placement="Bottom" 
                                       PlacementTarget="{Binding ElementName=PART_EditableTextBox}"
                                       StaysOpen="False"
                                       AllowsTransparency="True">
                                    <ListBox x:Name="autoCompleteListBox"
                                             ItemsSource="{Binding Source={StaticResource viewSource}}">
                                        <ListBox.ItemContainerStyle>
                                            <Style TargetType="ListBoxItem">
                                                <Setter Property="HorizontalContentAlignment" Value="Stretch" />
                                            </Style>
                                        </ListBox.ItemContainerStyle>
                                    </ListBox>
                                </Popup>
                            </Grid>
                            <ControlTemplate.Triggers>
                                <Trigger Property="UIElement.IsKeyboardFocusWithin">
                                    <Setter Property="TextElement.Foreground">
                                        <Setter.Value>
                                            <SolidColorBrush>#FF000000</SolidColorBrush>
                                        </Setter.Value>
                                    </Setter>
                                    <Trigger.Value>
                                        <s:Boolean>True</s:Boolean>
                                    </Trigger.Value>
                                </Trigger>
                                <Trigger Property="ComboBox.IsDropDownOpen">
                                    <Setter Property="mwt:ListBoxChrome.RenderFocused" TargetName="Border">
                                        <Setter.Value>
                                            <s:Boolean>True</s:Boolean>
                                        </Setter.Value>
                                    </Setter>
                                    <Trigger.Value>
                                        <s:Boolean>True</s:Boolean>
                                    </Trigger.Value>
                                </Trigger>
                                <Trigger Property="ItemsControl.HasItems">
                                    <Setter Property="FrameworkElement.Height" TargetName="DropDownBorder">
                                        <Setter.Value>
                                            <s:Double>95</s:Double>
                                        </Setter.Value>
                                    </Setter>
                                    <Trigger.Value>
                                        <s:Boolean>False</s:Boolean>
                                    </Trigger.Value>
                                </Trigger>
                                <Trigger Property="UIElement.IsEnabled">
                                    <Setter Property="TextElement.Foreground">
                                        <Setter.Value>
                                            <DynamicResource ResourceKey="{x:Static SystemColors.GrayTextBrushKey}" />
                                        </Setter.Value>
                                    </Setter>
                                    <Setter Property="Panel.Background">
                                        <Setter.Value>
                                            <SolidColorBrush>#FFF4F4F4</SolidColorBrush>
                                        </Setter.Value>
                                    </Setter>
                                    <Trigger.Value>
                                        <s:Boolean>False</s:Boolean>
                                    </Trigger.Value>
                                </Trigger>
                                <Trigger Property="ItemsControl.IsGrouping">
                                    <Setter Property="ScrollViewer.CanContentScroll">
                                        <Setter.Value>
                                            <s:Boolean>False</s:Boolean>
                                        </Setter.Value>
                                    </Setter>
                                    <Trigger.Value>
                                        <s:Boolean>True</s:Boolean>
                                    </Trigger.Value>
                                </Trigger>
                                <Trigger Property="Popup.HasDropShadow" SourceName="PART_Popup">
                                    <Setter Property="FrameworkElement.Margin" TargetName="Shdw">
                                        <Setter.Value>
                                            <Thickness>0,0,5,5</Thickness>
                                        </Setter.Value>
                                    </Setter>
                                    <Setter Property="mwt:SystemDropShadowChrome.Color" TargetName="Shdw">
                                        <Setter.Value>
                                            <Color>#71000000</Color>
                                        </Setter.Value>
                                    </Setter>
                                    <Trigger.Value>
                                        <s:Boolean>True</s:Boolean>
                                    </Trigger.Value>
                                </Trigger>
                            </ControlTemplate.Triggers>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
                <Trigger.Value>
                    <s:Boolean>True</s:Boolean>
                </Trigger.Value>
            </Trigger>
        </Style.Triggers>

        <Setter Property="FrameworkElement.FocusVisualStyle">
            <Setter.Value>
                <Style TargetType="IFrameworkInputElement">
                    <Style.Resources>
                        <ResourceDictionary />
                    </Style.Resources>
                    <Setter Property="Control.Template">
                        <Setter.Value>
                            <ControlTemplate>
                                <Rectangle Stroke="#FF000000" StrokeThickness="1" StrokeDashArray="1 2" Margin="4,4,21,4" SnapsToDevicePixels="True" />
                            </ControlTemplate>
                        </Setter.Value>
                    </Setter>
                </Style>
            </Setter.Value>
        </Setter>
        <Setter Property="TextElement.Foreground">
            <Setter.Value>
                <DynamicResource ResourceKey="{x:Static SystemColors.WindowTextBrushKey}" />
            </Setter.Value>
        </Setter>
        <Setter Property="Panel.Background">
            <Setter.Value>
                <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
                    <LinearGradientBrush.GradientStops>
                        <GradientStop Color="#FFF3F3F3" Offset="0" />
                        <GradientStop Color="#FFEBEBEB" Offset="0.5" />
                        <GradientStop Color="#FFDDDDDD" Offset="0.5" />
                        <GradientStop Color="#FFCDCDCD" Offset="1" />
                    </LinearGradientBrush.GradientStops>
                </LinearGradientBrush>
            </Setter.Value>
        </Setter>
        <Setter Property="Border.BorderBrush">
            <Setter.Value>
                <SolidColorBrush>#FF707070</SolidColorBrush>
            </Setter.Value>
        </Setter>
        <Setter Property="Border.BorderThickness">
            <Setter.Value>
                <Thickness>1,1,1,1</Thickness>
            </Setter.Value>
        </Setter>
        <Setter Property="ScrollViewer.HorizontalScrollBarVisibility">
            <Setter.Value>
                <x:Static Member="ScrollBarVisibility.Auto" />
            </Setter.Value>
        </Setter>
        <Setter Property="ScrollViewer.VerticalScrollBarVisibility">
            <Setter.Value>
                <x:Static Member="ScrollBarVisibility.Auto" />
            </Setter.Value>
        </Setter>
        <Setter Property="Control.Padding">
            <Setter.Value>
                <Thickness>4,3,4,3</Thickness>
            </Setter.Value>
        </Setter>
        <Setter Property="Control.Template">
            <Setter.Value>
                <ControlTemplate TargetType="ComboBox">
                    <Grid Name="MainGrid" SnapsToDevicePixels="True">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*" />
                            <ColumnDefinition Width="0" MinWidth="{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}" />
                        </Grid.ColumnDefinitions>
                        <Popup IsOpen="False" Placement="Bottom" PopupAnimation="{DynamicResource {x:Static SystemParameters.ComboBoxPopupAnimationKey}}" AllowsTransparency="True" Name="PART_Popup" Margin="1,1,1,1" Grid.ColumnSpan="2">
                            <mwt:SystemDropShadowChrome Color="#00FFFFFF" Name="Shdw" MinWidth="0" MaxHeight="{TemplateBinding ComboBox.MaxDropDownHeight}">
                                <Border BorderThickness="1,1,1,1" BorderBrush="{DynamicResource {x:Static SystemColors.WindowFrameBrushKey}}" Background="{DynamicResource {x:Static SystemColors.WindowBrushKey}}" Name="DropDownBorder">
                                    <ScrollViewer CanContentScroll="True">
                                        <ItemsPresenter SnapsToDevicePixels="{TemplateBinding UIElement.SnapsToDevicePixels}" KeyboardNavigation.DirectionalNavigation="Contained" />
                                    </ScrollViewer>
                                </Border>
                            </mwt:SystemDropShadowChrome>
                        </Popup>
                        <ToggleButton IsChecked="False" BorderBrush="{TemplateBinding Border.BorderBrush}" Background="{TemplateBinding Panel.Background}" Grid.ColumnSpan="2">
                            <ToggleButton.Style>
                                <Style TargetType="ToggleButton">
                                    <Style.Resources>
                                        <ResourceDictionary />
                                    </Style.Resources>
                                    <Setter Property="FrameworkElement.OverridesDefaultStyle">
                                        <Setter.Value>
                                            <s:Boolean>True</s:Boolean>
                                        </Setter.Value>
                                    </Setter>
                                    <Setter Property="KeyboardNavigation.IsTabStop">
                                        <Setter.Value>
                                            <s:Boolean>False</s:Boolean>
                                        </Setter.Value>
                                    </Setter>
                                    <Setter Property="UIElement.Focusable">
                                        <Setter.Value>
                                            <s:Boolean>False</s:Boolean>
                                        </Setter.Value>
                                    </Setter>
                                    <Setter Property="ButtonBase.ClickMode">
                                        <Setter.Value>
                                            <x:Static Member="ClickMode.Press" />
                                        </Setter.Value>
                                    </Setter>
                                    <Setter Property="Control.Template">
                                        <Setter.Value>
                                            <ControlTemplate TargetType="ToggleButton">
                                                <mwt:ButtonChrome Background="{TemplateBinding Panel.Background}" BorderBrush="{TemplateBinding Border.BorderBrush}" RenderMouseOver="{TemplateBinding UIElement.IsMouseOver}" RenderPressed="{TemplateBinding ButtonBase.IsPressed}" Name="Chrome" SnapsToDevicePixels="True">
                                                    <Grid Width="{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}" HorizontalAlignment="Right">
                                                        <Path Data="M0,0L3.5,4 7,0z" Fill="#FF000000" Name="Arrow" Margin="3,1,0,0" HorizontalAlignment="Center" VerticalAlignment="Center" />
                                                    </Grid>
                                                </mwt:ButtonChrome>
                                                <ControlTemplate.Triggers>
                                                    <Trigger Property="ToggleButton.IsChecked">
                                                        <Setter Property="mwt:ButtonChrome.RenderPressed" TargetName="Chrome">
                                                            <Setter.Value>
                                                                <s:Boolean>True</s:Boolean>
                                                            </Setter.Value>
                                                        </Setter>
                                                        <Trigger.Value>
                                                            <s:Boolean>True</s:Boolean>
                                                        </Trigger.Value>
                                                    </Trigger>
                                                    <Trigger Property="UIElement.IsEnabled">
                                                        <Setter Property="Shape.Fill" TargetName="Arrow">
                                                            <Setter.Value>
                                                                <SolidColorBrush>#FFAFAFAF</SolidColorBrush>
                                                            </Setter.Value>
                                                        </Setter>
                                                        <Trigger.Value>
                                                            <s:Boolean>False</s:Boolean>
                                                        </Trigger.Value>
                                                    </Trigger>
                                                </ControlTemplate.Triggers>
                                            </ControlTemplate>
                                        </Setter.Value>
                                    </Setter>
                                </Style>
                            </ToggleButton.Style>
                        </ToggleButton>
                        <ContentPresenter Content="{TemplateBinding ComboBox.SelectionBoxItem}" ContentTemplate="{TemplateBinding ComboBox.SelectionBoxItemTemplate}" Margin="{TemplateBinding Control.Padding}" HorizontalAlignment="{TemplateBinding Control.HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding Control.VerticalContentAlignment}" SnapsToDevicePixels="{TemplateBinding UIElement.SnapsToDevicePixels}" IsHitTestVisible="False" />
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="Popup.HasDropShadow" SourceName="PART_Popup">
                            <Setter Property="FrameworkElement.Margin" TargetName="Shdw">
                                <Setter.Value>
                                    <Thickness>0,0,5,5</Thickness>
                                </Setter.Value>
                            </Setter>
                            <Setter Property="mwt:SystemDropShadowChrome.Color" TargetName="Shdw">
                                <Setter.Value>
                                    <Color>#71000000</Color>
                                </Setter.Value>
                            </Setter>
                            <Trigger.Value>
                                <s:Boolean>True</s:Boolean>
                            </Trigger.Value>
                        </Trigger>
                        <Trigger Property="ItemsControl.HasItems">
                            <Setter Property="FrameworkElement.Height" TargetName="DropDownBorder">
                                <Setter.Value>
                                    <s:Double>95</s:Double>
                                </Setter.Value>
                            </Setter>
                            <Trigger.Value>
                                <s:Boolean>False</s:Boolean>
                            </Trigger.Value>
                        </Trigger>
                        <Trigger Property="UIElement.IsEnabled">
                            <Setter Property="TextElement.Foreground">
                                <Setter.Value>
                                    <DynamicResource ResourceKey="{x:Static SystemColors.GrayTextBrushKey}" />
                                </Setter.Value>
                            </Setter>
                            <Setter Property="Panel.Background">
                                <Setter.Value>
                                    <SolidColorBrush>#FFF4F4F4</SolidColorBrush>
                                </Setter.Value>
                            </Setter>
                            <Trigger.Value>
                                <s:Boolean>False</s:Boolean>
                            </Trigger.Value>
                        </Trigger>
                        <Trigger Property="ItemsControl.IsGrouping">
                            <Setter Property="ScrollViewer.CanContentScroll">
                                <Setter.Value>
                                    <s:Boolean>False</s:Boolean>
                                </Setter.Value>
                            </Setter>
                            <Trigger.Value>
                                <s:Boolean>True</s:Boolean>
                            </Trigger.Value>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

</ResourceDictionary>